<template>
  <el-card shadow="nerve" class="card">
    <el-form ref="form" :model="form" inline>
      <!-- 这里搜索账号和姓名都用一个username -->
      <!-- <el-form-item label="账号名" prop="username">
        <el-input v-model="form.username"></el-input>
      </el-form-item> -->
      <el-form-item label="关键字查询" prop="keyword">
        <el-input clearable @change="changeKeyword" v-model="form.keyword" placeholder="请输入用户名或姓名"></el-input>
      </el-form-item>
      <el-form-item label="手机号码" prop="phone"  v-show="devType != 'platform'">
        <el-input v-model="form.phone"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" size="small" @click="$emit('on-search', form)">查询</el-button>
        <el-button size="small" @click="onReset">重置</el-button>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<script>
export default {
  emits: ['on-search'],
  props: {
    orgId: {
      type: String,
      require: true,
    },
    onSearch: {
      type: Function,
      require: true,
    },
    devType:{ //平台模块使用
      type:String,
      default: 'a',
    },
  },
  data() {
    return {
      form: {
        // username: null,
        // cname: null,
        phone: null,
        orgId: this.orgId,
        keyword:null
      },
    }
  },
  methods: {
    onReset() {
      this.form = {
        // username: null,
        // cname: null,
        phone: null,
        orgId: null,
        keyword:''
      }
      this.$emit('on-search', this.form)
    },
    changeKeyword(){
      this.$emit('on-search', this.form)
    }
  },
  beforeUnmount(){
    console.log('查询组件注销');
    // this.onReset()
  }
}
</script>

<style lang='scss' scoped>
.card {
  margin-left: 20px;
}
</style>
